﻿using Common;
using ForumEngine.Models;
using ViewModel;

namespace ViewServices
{
    class UserViewService : IUserViewService
    {
        public UserProfileModel GetUserProfile(long userId)
        {
            throw new System.NotImplementedException();
        }

        public UserModel GetUser(long userId)
        {
            using (var domainModel = new DataAccess.DomainModel())
            {
                var user = domainModel.Users.Find(userId);

                if (user == null)
                {
                    return null;
                }

                var model = new UserModel
                {
                    Id = user.Id,
                    IsModerator = false,
                    Name = user.DisplayName,
                    Url = MvcHelper.UrlHelper.RouteUrl(new { application = Constants.Applications.Profile.Name, action = Constants.Applications.Profile.Actions.User, id = user.Id })
                };

                return model;
            }
        }
    }
}
